<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ page session="false" %>
<%@ page isELIgnored ="false" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>
<%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags" %>
<script type="text/javascript">
//<![CDATA[
	(function(){
		$kdom.appendDojoProp("btn_dataview_new_save","label",KppModule.commonResource.save);
		$kdom.appendDojoProp("btn_dataview_new_cancel","label",KppModule.commonResource.cancel);
		DataViewEdit={
			${validator}
			addNew:function(){
				if(dijit.byId('form_dataview_edit').validate()){
					dojo.xhrPost({
						form:'form_dataview_edit',
						handleAs:'json',
						load:function(response){
							alert("success");
							dijit.byId("dialog_dataview_new").hide();
							DataView.refresh();
						},
						error:function(){
							alert("failed");
						}
					});
				}
			}
		};
	})();
//]]>
</script>
<span style="display:none">To solve IE7/8 script event tag problem.</span>
<div data-dojo-type="dijit/form/Form" id="form_dataview_edit" data-dojo-props="action:'${pageContext.request.contextPath}/cgi/app/inspector/${entity.id}/datanew'" 
	style="width:650;height:275px;">
	<div id="tab_dialog_dataview_${name}" data-dojo-type="dijit/layout/TabContainer" data-dojo-props="tabPosition:'left-h'">
		<input name="dataId" type="hidden" value="${dataId==null?'':dataId}"></input>
		<c:forEach items="${entity.groups}" var="g">
			<div data-dojo-type="dijit/layout/ContentPane" data-dojo-props="title:'${g.name}'">
				<table width="100%">
					<tr>
						<c:set var="index" value="0"></c:set>
						<c:set var="cols" value="${entity.colspan*2}"></c:set>
						<c:forEach items="${g.properties}" var="p" varStatus="loopStatus">
							<c:set var="index" value="${index + p.colspan*2}"></c:set>
							<c:if test="${!loopStatus.first && index > cols}">
								</tr>
									<c:set var="index" value="${cols + p.colspan*2}"></c:set>
									<c:set var="cols" value="${cols + entity.colspan*2}"></c:set>
								<tr>
							</c:if>
							<c:if test="${p.type != 'one2many'}">
								<td>${p.label}</td>
								<td colspan="${p.colspan*2-1}">
									<c:choose>
										<c:when test="${!p.optionFlag}">
											<input name="${p.name}" id="dialog${p.name}${suffix}" required="${p.required}" value="${valueMap==null?'':valueMap[p.name]}" data-dojo-type="${p.showType}" style="width:${p.width};"
												data-dojo-props="constraints:${p.constraints},regExp:'${p.regExp}'"/>
										</c:when>
										<c:otherwise>
											<select name="${p.name}" id="dialog${p.name}${suffix}" required="${p.required}" data-dojo-type="dijit.form.Select" style="width:${p.width};"
												data-dojo-props="">
												<c:forEach items="${p.options}" var="o">
													<option value="${o.id}">${o.label}</option>
												</c:forEach>
											</select>
										</c:otherwise>
									</c:choose>
								</td>
							</c:if>
						</c:forEach>
					</tr>
				</table>
			</div>
		</c:forEach>
	</div>
</div>
<div data-dojo-type="dijit.layout.ContentPane" style="height:50px;">
	<div style="text-align:center;">
		<div id="dataview_new_button" style="float:left;margin:0 0 0 20px;">
			<div id="btn_dataview_new_save" data-dojo-type="dijit/form/Button" data-dojo-props="iconClass:'dijitEditorIcon dijitEditorIconSave', showLabel:true" style="width:70px;">
				<script type="dojo/on" data-dojo-event="click" data-dojo-args="evt">
					DataViewEdit.addNew();
				</script>	
			</div>
		</div>
		<div id="btn_dataview_new_cancel" data-dojo-type="dijit/form/Button" data-dojo-props="iconClass:'dijitEditorIcon dijitEditorIconUndo', showLabel:true" style="width:70px;">
			<script type="dojo/on" data-dojo-event="click" data-dojo-args="evt">
				dijit.byId("dialog_dataview_new").hide();
			</script>
		</div>
	</div>
</div>